package com.cardetective.shopcar.network.api

import com.android.base_network.data.BaseResponse
import com.cardetective.shopcar.network.model.AddCarPost
import com.cardetective.shopcar.network.model.BindMobilePost
import com.cardetective.shopcar.network.model.GoodsAllModel
import com.cardetective.shopcar.network.model.GoodsDetailInfoModel
import com.cardetective.shopcar.network.model.GoodsListInfoModel
import com.cardetective.shopcar.network.model.LoginAndRegisterInfo
import com.cardetective.shopcar.network.model.LoginPost
import com.cardetective.shopcar.network.model.ShopCarModel
import com.cardetective.shopcar.network.model.SubmitOrderModel
import kotlinx.coroutines.flow.Flow
import retrofit2.http.Body
import retrofit2.http.Field
import retrofit2.http.FormUrlEncoded
import retrofit2.http.GET
import retrofit2.http.POST
import retrofit2.http.Query

/**
 * 商品相关
 * */
interface GoodsApi {

    // 获取分类
    @GET("/v3/goods/getAllCategory")
    fun getAllCategory(@Query("parentId") parentId: String = "0"): Flow<BaseResponse<List<GoodsAllModel>>>

    // 获取商品列表
    @GET("/v3/goods/getGoodsByPage")
    fun getGoodsList(
        @Query("categoryId") categoryId: String,
        @Query("pageNumber") page: Int,
        @Query("pageSize") pageSize: Int,
    ): Flow<BaseResponse<GoodsListInfoModel>>

    // 商品详情
    @GET("/v3/goods/getGoodsDetail")
    fun getGoodsDetail(
        @Query("goodsId") goodsId: String,
    ): Flow<BaseResponse<GoodsDetailInfoModel>>

    // 通过sku查看商品详情
    @GET("/v3/goods/getGoodsSkuDetail")
    fun getGoodsBySkuDetail(
        @Query("goodsId") goodsId: String,
        @Query("goodsSkuId") goodsSkuId: String
    ): Flow<BaseResponse<GoodsDetailInfoModel>>

    // 添加购物车
    @FormUrlEncoded
    @POST("/v3/goodsCar/addCar")
    fun addCar(
        @Field("cartType") cartType: String,
        @Field("num") num: Int,
        @Field("skuId") skuId: String,
    ): Flow<BaseResponse<String>>

    // 购物车---列表
    @GET("/v3/goodsCar/getCarData")
    fun getCarData(): Flow<BaseResponse<ShopCarModel>>

    // 购物车---全选/全不选
    @FormUrlEncoded
    @POST("/v3/goodsCar/checkedGoodsIncar")
    fun checkAllGoodsCar(
        @Field("checked") checked: Boolean,
    ): Flow<BaseResponse<String>>

    // 购物车---店铺是否选中
    @FormUrlEncoded
    @POST("/v3/goodsCar/checkedStoreIncar")
    fun checkedStoreCar(
        @Field("checked") checked: Boolean,
        @Field("storeId") storeId: String,
    ): Flow<BaseResponse<String>>

    // 购物车---商品增加数量
    @FormUrlEncoded
    @POST("/v3/goodsCar/updataGoodsInCar")
    fun updateGoodsInCar(
        @Field("num") num: Int,
        @Field("skuId") skuId: String,
    ): Flow<BaseResponse<String>>

    // 购物车---删除商品
    @FormUrlEncoded
    @POST("/v3/goodsCar/deleteGoodsIncar")
    fun deleteGoodsInCar(
        @Field("skuIds") skuId: String,
    ): Flow<BaseResponse<String>>

    // 购物车---提交订单
    @FormUrlEncoded
    @POST("/v3/goodsCar/sumbitCar")
    fun submitCarOrder(
        @Field("cartType") skuId: String,
    ): Flow<BaseResponse<SubmitOrderModel>>

    // 购物车---选择某个商品进购物车
    @FormUrlEncoded
    @POST("/v3/goodsCar/checkedSingleGoodsIncar")
    fun checkedSingleGoodInCar(
        @Field("skuId") skuId: String,
        @Field("checked") checked: Boolean,
    ): Flow<BaseResponse<String>>

    // 购物车---统计商品
    @GET("/v3/goodsCar/calCarGoods")
    fun calCarGoods(
        @Query("cartType") cartType: String,
    ): Flow<BaseResponse<ShopCarModel>>

    // 获取支付参数
    @GET("/v3/pay/payment")
    fun payment(
        @Query("payType") payType: String,
        @Query("sn") sn: String
    ): Flow<BaseResponse<String>>



}